package com.ellecity06.common.utils

import android.annotation.SuppressLint
import android.content.Context
import com.google.gson.Gson

/**
 * @author ellecity06
 * @time 2023/3/29 14:51
 * @des
 */
val appContext: Context = AppUtils.getInstance().getApplication()
val gson :Gson by lazy { Gson() }
var netAvailable =true
class AppUtils {
    private var context: Context? = null
    var dialogShowing = false

    companion object {
        fun getInstance() = InstanceHelper.sSingle
    }

    fun getApplication(): Context {
        if (context == null)
            throw NullPointerException("Application 为空,请先在Application进行AppUtils初始化")
        return context!!
    }

    /**
     * 初始化操作
     */
    fun initializer(context: Context) {
        this.context = context
    }

    object InstanceHelper {
        @SuppressLint("StaticFieldLeak")
        val sSingle = AppUtils()
    }
}